package com.nseeod.util;

import java.io.*;
import java.nio.channels.*;

public class FileUtils {
	public static void copyFile(File in, File out) throws IOException {
		FileChannel inChannel = new FileInputStream(in).getChannel();
		FileChannel outChannel = new FileOutputStream(out).getChannel();
		try {
			inChannel.transferTo(0, inChannel.size(), outChannel);
			// or
			// outChannel.transferFrom
			// (inChannel, 0, inChannel.size());
		} catch (IOException e) {
			throw e;
		} finally {
			if (inChannel != null)
				inChannel.close();
			if (outChannel != null)
				outChannel.close();
		}
	}

	public static void deleteFile(File in) throws IOException {
		in.delete();

	}

	public static void main(String args[]) throws IOException {
		FileUtils.copyFile(new File(args[0]), new File(args[1]));
	}
}